home *** CD-ROM | disk | FTP | other *** search
/ Plug-In Power Pack for Netscape Communicator / Plug-In Power Pack for Netscape Communicator.iso / plugins / dataviews / dvtools / examples / utilities / setinputflag.c < prev    next >
Encoding:
C/C++ Source or Header  |  1997-05-08  |  4.7 KB  |  152 lines

  1. /*
  2. |  Utility name: SetInputFlag.c
  3. |
  4. |  USAGE:
  5. |
  6. |    SetInputFlag.x <viewfile> <viewfile> ... <viewfile>
  7. |
  8. |  DESCRIPTION:
  9. |
  10. |    Set the new flag REDRAW_ON_UPDATE (flag added at release 9.1) for
  11. |    all input objects found in the specified view(s).  The flag
  12. |    is set using the DV-Tools routine VOinPutFlag.  This flag
  13. |    allows the redrawing of obscuring objects that have been
  14. |    damaged by input object updates.
  15. */
  16.  
  17. /*
  18.  *  DV-Tools header files
  19.  */
  20. #include "std.h"                /* <stdio.h> etc., scalar & macro definitions */
  21. #include "dvstd.h"              /* public types & constants */
  22. #include "dvtools.h"            /* constants used by T routines */
  23. #include "dvinteract.h"         /* needed for input objects & event handler */
  24. #include "dvGR.h"               /* constants used by window mgt & GR routines */
  25. #include "VOstd.h"              /* constants used by VO & VOob routines */
  26. #include "Tfundecl.h"           /* T routines (screens, drawports & views) */
  27. #include "VOfundecl.h"          /* VO routines (objects) */
  28. #include "VNsetup.h"            /* info for interaction handlers */
  29.  
  30. /* Constants */
  31. #define  DVPATH            (CHAR *)NULL
  32. #define  DVCOLORTABLE      (CHAR *)NULL
  33.  
  34. /* Functions defined in SetInputFlag.c */
  35. int main V_P_((int argc, char *argv[]));
  36. LOCAL  ADDRESS SetInputFlag V_P_((OBJECT object, ADDRESS args));
  37. LOCAL  BOOLPARAM IsWidget V_P_((OBJECT input_tech));
  38. /***************** End Function Declarations *************/
  39.  
  40. /*
  41.  *  MAIN PROGRAM
  42.  */
  43. int 
  44. main (argc, argv)
  45.      int argc;
  46.      char *argv[];
  47. {
  48.   CHAR *view_name = NULL;
  49.   VIEW view;
  50.   INT i;
  51.  
  52.   (VOID) TInit (DVPATH, DVCOLORTABLE);
  53.   if (argc <= 1)
  54.     {
  55.       (VOID) S_PRINTF ("Name of view file to convert must be specified.\n");
  56.       S_EXIT (EXIT_ERR);
  57.     }
  58.  
  59.   for (i = 1; i < argc; ++i)
  60.     {
  61.       view_name = argv[i];
  62.       view = TviLoad (view_name);
  63.       if (!view)
  64.         {
  65.           (VOID) S_PRINTF ("Could not load view from file ");
  66.           (VOID) S_PRINTF ("%s.\n", view_name);
  67.           S_EXIT (EXIT_ERR);
  68.         }
  69.  
  70.       /*
  71.        *  For each object in the drawing of the specified view call
  72.        *  the function SetInputFlag.  This function will set the
  73.        *  flag for all input objects.
  74.        */
  75.       (VOID) TobForEachSubobject (TviGetDrawing (view), SetInputFlag,
  76.                                   (ADDRESS) NULL);
  77.       /*
  78.        *  Save changes made to objects in view and destroy
  79.        *  the current view freeing the allocated memory.
  80.        */
  81.       (VOID) S_PRINTF (
  82.          "REDRAW_ON_UPDATE flag set for input objects in view, %s.\n",
  83.                         view_name);
  84.       (VOID) TviSave (view, view_name);
  85.       (VOID) TviDestroy (view);
  86.     }
  87.  
  88.   /* Perform the clean-up for DV-Tools */
  89.   (VOID) TTerminate ();
  90.   return (EXIT_OK);
  91. }
  92.  
  93. /*--------------
  94.  *  SetInputFlag -- set the flag, REDRAW_ON_UPDATE, to yes
  95.  *            for all input objects except those which
  96.  *            which are widget-based.
  97.  */
  98. LOCAL ADDRESS 
  99. SetInputFlag (object, args)
  100.      OBJECT object;
  101.      ADDRESS args;
  102. {
  103.   OBJECT input_tech, template = (OBJECT) NULL;
  104.  
  105.   /*
  106.    *  If the object is an input object then get the interaction
  107.    *  handler.  Then set the REDRAW_ON_UPDATE flag to yes if
  108.    *  the interaction handler represents a non-widget-based
  109.    *  interaction handler.  Then obtain the template for the
  110.    *  interaction handler and traverse all the objects in the
  111.    *  template searching for embedded input objects.
  112.    */
  113.   if (VOobType (object) == OT_INPUT)
  114.     {
  115.       input_tech = VOinTechnique (object, (OBJECT) DONT_SET_THE_VALUE);
  116.  
  117.       /* Set the flag */
  118.       if (!IsWidget (input_tech))
  119.         (VOID) VOinPutFlag (object, (INT) REDRAW_ON_UPDATE, (INT) YES);
  120.  
  121.       /* Traverse the template for the embedded inputs */
  122.       template = VOitGetTemplate (input_tech);
  123.       if (template)
  124.         (VOID) VOdrTraverse (template, (VOOBTRAVERSEFUN)SetInputFlag, (ADDRESS) NULL);
  125.     }
  126.   else if (VOobType (object) == OT_SUBDRAWING)
  127.     (VOID) VOdrTraverse (VOsdDrGet (object), (VOOBTRAVERSEFUN)SetInputFlag, (ADDRESS) NULL);
  128.  
  129.   return (ADDRESS) V_CONTINUE_TRAVERSAL;
  130. }
  131.  
  132. /*----------
  133.  *  IsWidget -- Check to see if the passed input object
  134.  *        a DataViews widget-based input object.
  135.  *        The DataViews widget-based input objects
  136.  *        do not have a TakeInput state.
  137.  */
  138. LOCAL BOOLPARAM 
  139. IsWidget (input_tech)
  140.      OBJECT input_tech;
  141. {
  142.   ADDRESS (*GetDispatchTable) ()= NULL;
  143.   INT (**dispatch) ();
  144.  
  145.   GetDispatchTable = (ADDRESS (*)())VOitGetInteraction (input_tech);
  146.   if (GetDispatchTable)
  147.     dispatch = (INT (**)())(*GetDispatchTable) ((ADDRESS) 0);
  148.   if (!dispatch[IH_TAKE_INPUT])
  149.     return YES;
  150.   return NO;
  151. }
  152.